#include "task_factory.h"
#include "ftp_task_cmd.h"
#include "ftp_task_user.h"
#include "ftp_task_list.h"
#include "ftp_task_port.h"
#include "ftp_task_retr.h"
#include "ftp_task_stor.h"
#include "../util/common_util.h"

// 每次接到一个新链接都新建一个任务流程,流程中包括主要的命令处理器“FtpTaskCmd”，以及其下的calls
TaskBase *TaskFactory::CreateTask() {
	LOGDEBUG("At TaskFactory::CreateTask");
	FtpTaskCmd *x = new FtpTaskCmd();

	x->Reg("USER", new XFtpUSER());

	x->Reg("PORT", new FtpTaskPort());

	FtpTaskBase *list = new FtpTaskList();
	x->Reg("PWD", list);
	x->Reg("LIST", list);
	x->Reg("CWD", list);
	x->Reg("CDUP", list);

	x->Reg("RETR", new XFtpRETR());

	x->Reg("STOR", new XFtpSTOR());

	return x;
}